from agent.agent_selector import determine_agent
from agent.travel_assistant_agent import travel_assistant
from agent.content_creator_agent import content_creator
from agent.content_draw_agent import content_creator_with_text
from agent.travel_draw_agent import travel_creator_with_text
from tts.text_to_speech import generate_audio_from_text


def main():
    inputs = [
        "I want to travel to Paris, can you provide me with a travel plan?",
        # "please generate an analysis report for the stock Apple/BTC for the last quarter's performance"
    ]

    for user_input in inputs:
        print(f"用户输入: {user_input}")
        agent_type, model_response = determine_agent(user_input)

        if agent_type == "travel_assistant":
            response = travel_assistant(user_input)
            role_used = "travel_assistant"
        elif agent_type == "content_creator":
            response = content_creator(user_input)
            role_used = "content_creator"

            # 获取响应内容并写入 Markdown 文件
            markdown_content = f"# Response\n\n{response}\n"
            with open("output.md", "w", encoding="utf-8") as file:
                file.write(markdown_content)

        else:
            response = model_response
            role_used = "无法确定角色"

        # 调用 content_creator_with_keywords 获取绘图提示词
        prompt = content_creator_with_text(response)
        print(f"生成的绘图提示词: {prompt}")

        print(f"**使用的角色:** {role_used}")
        print(f"响应: {response}")
        # 从文件 tts/input.txt 中读取文本内容
        with open("tts/input.txt", "r", encoding="utf-8") as file:
            text = file.read()
        output_path = "./audio/output.mp3"
        generate_audio_from_text(text)


if __name__ == "__main__":
    main()
